; RUN: llvm-undname < %s | FileCheck %s

; CHECK-NOT: Invalid mangled name

?x@@3HA
; CHECK: int x

?x@@3PEAHEA
; CHECK: int *x

?x@@3PEAPEAHEA
; CHECK: int **x

?foo@@3Y123KA
; CHECK: unsigned long foo[3][4]

?x@@3PEAY02HEA
; CHECK: int (*x)[3]

?x@@3PEAY124HEA
; CHECK: int (*x)[3][5]

?x@@3PEAY02$$CBHEA
; CHECK: int const (*x)[3]

?x@@3PEAEEA
; CHECK: unsigned char *x

?y@@3PEAGEA
; CHECK: unsigned short *y

?z@@3PEAKEA
; CHECK: unsigned long *z

?x@@3PEAY1NKM@5HEA
; CHECK: int (*x)[3500][6]

?x@@YAXMH@Z
; CHECK: void __cdecl x(float, int)

?x@@YAXMHZZ
; CHECK: void __cdecl x(float, int, ...)

?x@@YAXZZ
; CHECK: void __cdecl x(...)

?x@@3P6AHMNH@ZEA
; CHECK: int (__cdecl *x)(float, double, int)

?x@@3P6AHP6AHM@ZN@ZEA
; CHECK: int (__cdecl *x)(int (__cdecl *)(float), double)

?x@@3P6AHP6AHM@Z0@ZEA
; CHECK: int (__cdecl *x)(int (__cdecl *)(float), int (__cdecl *)(float))

?x@ns@@3HA
; CHECK: int ns::x

; Microsoft's undname doesn't handle Q correctly or the multiple occurrences
; of the const modifier.  So the results here differ, but ours are correct.
?x@@3PEAHEA
; CHECK: int *x

?x@@3PEBHEB
; CHECK: int const *x

?x@@3QEAHEA
; CHECK: int *const x

?x@@3QEBHEB
; CHECK: int const *const x


?x@@3AEBHEB
; CHECK: int const &x

?x@@3PEAUty@@EA
; CHECK: struct ty *x

?x@@3PEATty@@EA
; CHECK: union ty *x

?x@@3PEAVty@@EA
; CHECK: class ty *x

?x@@3PEAW4ty@@EA
; CHECK: enum ty *x

?x@@3PEAV?$tmpl@H@@EA
; CHECK: class tmpl<int> *x

?x@@3PEAU?$tmpl@H@@EA
; CHECK: struct tmpl<int> *x

?x@@3PEAT?$tmpl@H@@EA
; CHECK: union tmpl<int> *x

?instance@@3Vklass@@A
; CHECK: class klass instance

?instance$initializer$@@3P6AXXZEA
; CHECK: void (__cdecl *instance$initializer$)(void)

??0klass@@QEAA@XZ
; CHECK: __cdecl klass::klass(void)

??1klass@@QEAA@XZ
; CHECK: __cdecl klass::~klass(void)

?x@@YAHPEAVklass@@AEAV1@@Z
; CHECK: int __cdecl x(class klass *, class klass &)

?x@ns@@3PEAV?$klass@HH@1@EA
; CHECK: class ns::klass<int, int> *ns::x

?fn@?$klass@H@ns@@QEBAIXZ
; CHECK: unsigned int __cdecl ns::klass<int>::fn(void) const


??4klass@@QEAAAEBV0@AEBV0@@Z
; CHECK: class klass const & __cdecl klass::operator=(class klass const &)

??7klass@@QEAA_NXZ
; CHECK: bool __cdecl klass::operator!(void)

??8klass@@QEAA_NAEBV0@@Z
; CHECK: bool __cdecl klass::operator==(class klass const &)

??9klass@@QEAA_NAEBV0@@Z
; CHECK: bool __cdecl klass::operator!=(class klass const &)

??Aklass@@QEAAH_K@Z
; CHECK: int __cdecl klass::operator[](unsigned __int64)

??Cklass@@QEAAHXZ
; CHECK: int __cdecl klass::operator->(void)

??Dklass@@QEAAHXZ
; CHECK: int __cdecl klass::operator*(void)

??Eklass@@QEAAHXZ
; CHECK: int __cdecl klass::operator++(void)

??Eklass@@QEAAHH@Z
; CHECK: int __cdecl klass::operator++(int)

??Fklass@@QEAAHXZ
; CHECK: int __cdecl klass::operator--(void)

??Fklass@@QEAAHH@Z
; CHECK: int __cdecl klass::operator--(int)

??Hklass@@QEAAHH@Z
; CHECK: int __cdecl klass::operator+(int)

??Gklass@@QEAAHH@Z
; CHECK: int __cdecl klass::operator-(int)

??Iklass@@QEAAHH@Z
; CHECK: int __cdecl klass::operator&(int)

??Jklass@@QEAAHH@Z
; CHECK: int __cdecl klass::operator->*(int)

??Kklass@@QEAAHH@Z
; CHECK: int __cdecl klass::operator/(int)

??Mklass@@QEAAHH@Z
; CHECK: int __cdecl klass::operator<(int)

??Nklass@@QEAAHH@Z
; CHECK: int __cdecl klass::operator<=(int)

??Oklass@@QEAAHH@Z
; CHECK: int __cdecl klass::operator>(int)

??Pklass@@QEAAHH@Z
; CHECK: int __cdecl klass::operator>=(int)

??Qklass@@QEAAHH@Z
; CHECK: int __cdecl klass::operator,(int)

??Rklass@@QEAAHH@Z
; CHECK: int __cdecl klass::operator()(int)

??Sklass@@QEAAHXZ
; CHECK: int __cdecl klass::operator~(void)

??Tklass@@QEAAHH@Z
; CHECK: int __cdecl klass::operator^(int)

??Uklass@@QEAAHH@Z
; CHECK: int __cdecl klass::operator|(int)

??Vklass@@QEAAHH@Z
; CHECK: int __cdecl klass::operator&&(int)

??Wklass@@QEAAHH@Z
; CHECK: int __cdecl klass::operator||(int)

??Xklass@@QEAAHH@Z
; CHECK: int __cdecl klass::operator*=(int)

??Yklass@@QEAAHH@Z
; CHECK: int __cdecl klass::operator+=(int)

??Zklass@@QEAAHH@Z
; CHECK: int __cdecl klass::operator-=(int)

??_0klass@@QEAAHH@Z
; CHECK: int __cdecl klass::operator/=(int)

??_1klass@@QEAAHH@Z
; CHECK: int __cdecl klass::operator%=(int)

??_2klass@@QEAAHH@Z
; CHECK: int __cdecl klass::operator>>=(int)

??_3klass@@QEAAHH@Z
; CHECK: int __cdecl klass::operator<<=(int)

??_6klass@@QEAAHH@Z
; CHECK: int __cdecl klass::operator^=(int)

??6@YAAEBVklass@@AEBV0@H@Z
; CHECK: class klass const & __cdecl operator<<(class klass const &, int)

??5@YAAEBVklass@@AEBV0@_K@Z
; CHECK: class klass const & __cdecl operator>>(class klass const &, unsigned __int64)

??2@YAPEAX_KAEAVklass@@@Z
; CHECK: void * __cdecl operator new(unsigned __int64, class klass &)

??_U@YAPEAX_KAEAVklass@@@Z
; CHECK: void * __cdecl operator new[](unsigned __int64, class klass &)

??3@YAXPEAXAEAVklass@@@Z
; CHECK: void __cdecl operator delete(void *, class klass &)

??_V@YAXPEAXAEAVklass@@@Z
; CHECK: void __cdecl operator delete[](void *, class klass &)

?A@?A0x43583946@@3VB@@B
; CHECK: class B const `anonymous namespace'::A
